package jdbc;

import java.sql.*;

public class JDBCDemo10 {
    public static void main(String[] args) {
//需求:根据用户id修改用户的密码，昵称，年龄
        try (Connection connection = DBUtil.getConnection();){
            String sql = "UPDATE userinfo " +
                    "SET password=?,nickname=?,age=? " +
                    "WHERE id=?";
            PreparedStatement ps = connection.prepareStatement(sql);
            ps.setString(1,"88888888");
            ps.setString(2,"小丽");
            ps.setInt(3,33);
            ps.setInt(4,15);
            int num = ps.executeUpdate();
            System.out.println(num>0?"修改成功":"修改失败");
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
